#!/bin/sh

NAME=MODULE_NAME
VERSION=MODULE_VERSION

set -e

case "$1" in
    remove|upgrade|deconfigure)
      if [  "`dkms status -m $NAME`" ]; then
         dkms remove -m $NAME -v $VERSION --all
      fi
      if [  "`ls /usr/src/$NAME-$VERSION 2> /dev/null`" ]; then
         rm -rf /usr/src/$NAME-$VERSION
      fi
      # Also cleanup old installations (to be removed at some point)
      if [  "`ls /usr/src/$NAME-* 2> /dev/null`" ]; then
         rm -rf /usr/src/$NAME-*
      fi
    ;;

    failed-upgrade)
    ;;

    *)
        echo "prerm called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

#DEBHELPER#

exit 0
